﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;


    public static class CoEncrypt
    {
        /// <summary>
        /// 用md5加密
        /// </summary>
        /// <param name="source">输入的数据</param>
        /// <returns></returns>
        public static string ToMD5(this string source)
        {
            byte[] b = Encoding.Default.GetBytes(source);
            b = new MD5CryptoServiceProvider().ComputeHash(b);
            string ret = "";

            for (int i = 0; i < b.Length; i++)
                ret += b[i].ToString("x").PadLeft(2, '0');

            return ret;
        }
    }

